import { generateUUID } from '@/utils/tools';
/**
 * 采集方式设置
 *
*/
export default {
  data() {
    return {
      collectWaysOptions: [// 3.4.0取消日更选项
        { label: '手动', value: 0 },
        { label: '周更', value: 2 },
        { label: '月更', value: 3 },
        { label: '自定义', value: 4 }
      ],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() < Date.now();
        }
      }
    };
  },
  methods: {
    changeCollectWays() {
      if (this.form.collectWay !== 0) {
        this.form.collectDate = [{ time: null, _uuid: generateUUID() }];
      }
    },
    handleAdd() {
      if (this.form.collectDate.length > 4) {
        this.$message.error('最多可设置五个采集日期');
        return;
      }
      this.form.collectDate.push({ time: null, _uuid: generateUUID() });
    },
    handleDel(index) {
      this.form.collectDate.splice(index, 1);
    },
    disabledDate(way) {
      const ways = [2, 3, 4];
      return ways.includes(way);
    }
  }
};
